package com.dxy.server.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @Description Properties工具类
 * @Author dangxianyue
 * @Date 2023/3/19 20:58
 */
public class PropertiesUtil {

    private static Properties properties;

    static {
        try {
            properties = new Properties();
            ClassLoader loader=Thread.currentThread().getContextClassLoader();
            InputStream inStream=loader.getResourceAsStream("server.properties");
            properties.load(inStream);
            System.out.println("properties: " + properties);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static String getProperty(String key) {
        return properties.getProperty(key);
    }

    public static String getProperty(String key, String defaultValue) {
        return properties.getProperty(key, defaultValue);
    }

}
